//
//  MPMNetRequestModel.h
//  MiaoPai
//
//  Created by jiaxuzhou on 2017/5/24.
//  Copyright © 2017年 jiaxuzhou. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "MPBNetWorking.h"
#import "MPCURLSessionTask+MPCNetWork.h"


typedef NS_OPTIONS(NSUInteger, GMNetDependencyType) {
    GMNetDependencySuccess              = 1 << 0,
    GMNetDependencyFailed               = 1 << 1,
    GMNetDependencyCancel               = 1 << 2,
    GMNetDependencyAll                  = (1 << 3) -1
};


@interface MPMNetRequestModel : NSObject


/**
 请求方法
 */
- (MPMNetRequestModel * (^)(MPE_NetMethod))method;

/**
 请求地址
 */
- (MPMNetRequestModel * (^)(NSString *))url;

/**
 请求参数
 */
- (MPMNetRequestModel * (^)(NSDictionary *))params;


/**
 是否显示无网提示
 */
- (MPMNetRequestModel * (^)(BOOL))showNoNetAlert;

/**
 成功回调
 */
- (MPMNetRequestModel * (^)(MPHNetFinishedBlock))success;

/**
 失败回调
 */
- (MPMNetRequestModel * (^)(MPHNetFinishedBlock))failed;

/**
 读取缓存回调
 */
- (MPMNetRequestModel * (^)(MPHNetCatcheBlock))cache;

/**
 会话过期会回调此block
 */
- (MPMNetRequestModel * (^)(void (^)(MPE_NetWorkSessionState state)))sessionTimeout;

/**
 无网络提示
 */
- (MPMNetRequestModel * (^)(MPHNoNetWorkBlock))noNetWorkBlock;

/**
 网络请求失败时是否需要弹框提示。YES（默认）有弹框提示；NO 无弹框提示
 */
- (MPMNetRequestModel * (^)(BOOL))showToast;

/**
 网络请求参数是否加密
 */
- (MPMNetRequestModel * (^)(BOOL))isEncrypt;

/**
 网络请求超时时间
 */
- (MPMNetRequestModel * (^)(CGFloat))timeout;

/**
 task优先级
 */

- (MPMNetRequestModel * (^)(CGFloat))priority;

/**
 设置网络请求对象类型
 */
- (MPMNetRequestModel * (^)(Class))requestTypeClass;

/**
 依赖请求
 */
- (MPMNetRequestModel * (^)(MPMNetRequestModel *))depend;

/**
 依赖类型，默认 success
 */
- (MPMNetRequestModel * (^)(GMNetDependencyType))optionDepend;

/// api新旧版
- (MPMNetRequestModel * (^)(BOOL))oldApi;
/// response加密方式
- (MPMNetRequestModel * (^)(MPE_NetRespSecType))responseSecType;

/**
 发送异步网络请求
 */
- (void)request;

/**
 发送同步网络请求
 */
- (void)syncRequest;

/**
 发送一组可配置依赖的网络请求

 @param requests request对象数组
 */
+ (void)requset:(NSArray *)requests;

/**
 创建对象

 @return MPMNetRequestModel
 */
+ (instancetype)defaultModel;


@end
